import request from "@/utils/http/axios";

class SkuApi {

  static list(page, size, keyword = "") {
    return request({
      url: "/sku/list",
      method: "get",
      params: { page, size, keyword },
    });
  }

  static addOrUpdate(sku){
    return request({
      url: "/sku/addOrUpdate",
      method: "post",
      data: sku
    })
  }

  static import(file) {
    const formData = new FormData();
    formData.append('file', file);
    return request({
      url: "/sku/import",
      method: "post",
      data: formData,
      headers: {
        "Content-Type": "multipart/form-data",
      },
    });
  }

  static downloadTemplate(){
    return request({
      url: "/sku/template",
      method: "get",
      // responseType: "blob"
      responseType: "arraybuffer"

    })
  }

  static getSupplierList(){
    return request({
      url: "/supplier/list",
      method: "get",
    })
  }

  static export(ids){
    return request({
      url: "/sku/export?ids="+ids,
      method: "get",
      responseType: "arraybuffer"
    })
  }

  static updateSkuCategory(categoryId, skuIds){
    return request({
      url: "/sku/updateSkuCategory",
      method: "post",
      data: {categoryId, skuIds}
    })
  }
}

export default SkuApi;
